import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import Index from '../views/index'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home,
    redirect:'/index',
    children:[
      {
        path:'/index',
        name:'Index',
        component: Index
      },
      {
        path: '/product/:id',
        name: "product",
        component: ()=>import('../views/product')
      },
      {
        path: '/detail/:id',
        name: 'detail',
        component: ()=>import('../views/detail')
      }
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: ()=>import('../views/login')
  },
  {
    path: '/cart',
    name: 'cart',
    component: ()=>import('../views/cart')
  },
  {
    path: '/order',
    name: 'order',
    component: ()=>import('../views/order'),
    children: [
      {
        path: '/orderlist',
        name: 'orderList',
        component: ()=>import('../views/orderList')
      },
      {
        path: '/orderconfirm',
        name: 'orderConfirm',
        component: ()=>import('../views/orderConfirm')
      },
      {
        path: '/orderplay',
        name: 'orderPlay',
        component: ()=>import('../views/orderPlay')
      },
      {
        path: '/alipay',
        name: 'alipay',
        component: ()=>import('../views/alipay')
      }
    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
